package com.xhwl.logistics.service.business;

import com.xhwl.logistics.bo.VehicleAccessRecordRealtimeBO;
import com.xhwl.logistics.bo.VehicleAccessRecordSecondBO;
import com.xhwl.logistics.bo.cent.VehicleIntegratedConfigBO;
import com.xhwl.logistics.bo.input.QueryVehicleAccessRecordRealtimeBO;
import com.xhwl.logistics.component.LookupVehicleParkingLotHandler;
import com.xhwl.logistics.converter.mapstruct.VehicleAccessRecordRealtimeConverter;
import com.xhwl.logistics.service.cent.QueryDeviceService;
import com.xhwl.logistics.strategy.IVehicleParkingLotHandler;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.List;

//@Service
public class VehicleAccessRecordRealtimeBusinessService {

    @Autowired
    private LookupVehicleParkingLotHandler lookupVehicleParkingLotHandler;

    @Autowired
    private QueryDeviceService queryDeviceService;

    @Autowired
    private VehicleAccessRecordRealtimeConverter accessRecordRealtimeConverter;

    public VehicleAccessRecordRealtimeBO queryAccessRecordRealtime(QueryVehicleAccessRecordRealtimeBO queryVehicleAccessRecordRealtimeBO) {
        VehicleIntegratedConfigBO vehicleIntegratedConfigBO = queryDeviceService.queryIntegratedConfigFromProjectId(queryVehicleAccessRecordRealtimeBO.getProjectId());

        IVehicleParkingLotHandler vehicleParkingLotHandler = lookupVehicleParkingLotHandler.lookup(vehicleIntegratedConfigBO.getVehicleSystemInfoBO().getProductId());

        List<VehicleAccessRecordSecondBO> vehicleAccessRecordSecondBOList = vehicleParkingLotHandler.queryAccessRecordRealtime(vehicleIntegratedConfigBO, queryVehicleAccessRecordRealtimeBO);
        return accessRecordRealtimeConverter.toVehicleAccessRecordRealtimeBO(vehicleAccessRecordSecondBOList);
    }

}
